package com.first.xiinn.dao.impl;

import java.util.List;
import com.first.core.dao.impl.BaseDaoImpl;
import com.first.xiinn.dao.BookTypeDao;
import com.first.xiinn.model.BookType;

public class BookTypeDaoImpl extends BaseDaoImpl<BookType> implements
		BookTypeDao {

	public BookTypeDaoImpl() {
		super(BookType.class);
	}

	public List<BookType> findByParentId(String parentId) {
		String hql = "from BookType b where b.parentId=?";
		Object[] params = { parentId };
		return findByHql(hql, params);
	}

	public BookType get(String bookTypeId) {
		String hql = "from BookType b where b.bookCatalogId=?";
		Object[] params = { bookTypeId };
		List<BookType>  bookTypes = findByHql(hql, params);
		if(bookTypes.size() >0 ){
			return bookTypes.get(0);
		}else{
			return null;
		}
	}
}
